1. Field of the Invention
The present invention relates to a computer-aided image processing apparatus, and, more particularly, an image processing apparatus capable of efficiently performing a computation for processing of a plurality of polygons and a computation for a hidden-surface process in a rendering process with fewer hardware, an image processing method for the image processing apparatus, and a recording medium on which an image processing program for accomplishing the method is recorded.
2. Description of the Related Art
Computer-aided image processing apparatuses are widely used in game machines and simulation apparatuses. In such an image processing apparatus, a game program or a simulation program generates polygons which form an object to be displayed. This polygon data normally includes parameters for each vertex. The vertex parameters include, for example, the coordinates of each vertex in three-dimensional (3D) space, the texture coordinates of the vertex, a normal vector, an alpha value representing transparency and color related data.
First, polygons in the display screen are clipped based on the polygon data, and for the clipped polygons, the 3D coordinates of the vertexes are scan-converted to two-dimensional (2D) coordinates on the display screen and Z values indicating the depths in accordance with the view point. Then, image data of the pixels of polygons to be displayed in the display screen are acquired by a rendering process. This image data has color data of RGB, for example.
In the rendering process, computation of the parameters of the pixels in a polygon is normally carried out by specifying the pixel coordinates in the polygon by raster scanning and performing interpolation of the vertex parameters according to the pixel coordinates. That is, the internal ratio is acquired from the vertex coordinates and the pixel coordinates and interpolation of the vertex parameters is executed according to the internal ratio.
Further, the rendering process is implemented frame by frame. In the rendering process, a Z value indicating the depth of a pixel of a polygon is used in a hidden-surface process which determines a polygon to be displayed pixel by pixel. In a case of the minimum Z value (that of the foremost pixel in the display screen), found through comparison, the color data is stored in a frame buffer memory. Therefore, a Z-value buffer memory is used to store the pixel's Z value stored in the frame buffer memory.
The interpolation in the raster scanning scheme computes the coordinates and parameters of edge points on a line which connects vertexes and computes the coordinates and parameters of pixels lying between the edge points on both sides. This interpolation generally includes an division operation which places the greatest load on the computation circuitry of a computer. As interpolation involved in raster scanning is carried out frequently, the high-load operation should be avoided as much as possible.
In the rendering process on opaque polygons, comparison of Z values is executed to set valid the pixels of a foreground polygon in the display screen. In this computation, for example, the Z value of the foremost pixel is stored in the Z-value buffer memory and image data is stored in the frame buffer memory one after another. According to this scheme, generation of image data of a polygon positioned at a deeper location and a process of writing image data in the frame buffer memory become wasteful due to the existence of a polygon on a more foreground side which is executed later. This results in a lower processing efficiency.
As a scheme of avoiding the efficiency reduction, the ID of a polygon may be stored in the Z-value buffer memory pixel by pixel until all the pixels to be displayed are eventually determined. This scheme may likewise make writing of the polygon ID in the Z-value buffer memory wasted, resulting in a lower processing efficiency.
The rendering process for translucent polygons, which are neither opaque nor transparent, should blend the color of a polygon located deep on the display screen with the color of a polygon located in the foreground. In this case, after temporary sorting of translucent polygons according to their Z values, the blending process is carried in order from the deepest polygon. This sorting process however involves, for example, comparison of Z values, which reduces the processing efficiency.
In the image processing, a shadow portion which is formed by the light source should undergo a shadowing process (which casts a shadow) that does not involve such a process as to increase the luminance in accordance with the light from the light source. Various complex algorithms for such shadowing process have been proposed, but they all require complicated computation, thus resulting in a lower processing efficiency.
FIG. 53 is a diagram for explaining raster scanning of a polygon. In the example of FIG. 53, pixels inside a polygon 10 that is specified by vertexes L, M and N are raster-scanned. For instance, scanning is carried out in the lateral direction, starting with the vertex L, and the scan line is shifted along the Y axis. Assume that a given pixel P is positioned on the scan line that connects a point O of a side LM and a point Q of a side LN. To acquire the edge coordinates (x.sub.o, y.sub.o) and (x.sub.q, y.sub.q) of a scan line OQ from the coordinates of a scan line RS before the scan line OQ, therefore, the following computation should be performed. EQU dx.sub.LM /dy.sub.LM =(x.sub.o -x.sub.r)/(y.sub.o -y.sub.r)
dx.sub.LN /dy.sub.LN =(x.sub.q -x.sub.s)/(y.sub.q -y.sub.s).
Given that y.sub.0 -y.sub.r =1 and y.sub.q -y.sub.s =1, then EQU x.sub.o =x.sub.r +dx.sub.LM /dy.sub.LM EQU x.sub.q =x.sub.s +dx.sub.LN /dy.sub.LN.
As the above computation includes division operations including the inclinations of the lines LM and LN, the computation load on the computer become large. In a case of division, processing of a value below a decimal point takes time too. Those calculations are frequently required in raster-scanning of a polygon, and should be carried out for all the polygons.
Further, the aforementioned Z-value buffer memory with a capacity of one frame means that the image processing apparatus requires excessive hardware.